import './index.scss'
import {useState,useEffect} from 'react'
import {getAll} from '../../request/api'
import {useNavigate} from 'react-router-dom'
const All=()=>{
    const Navigate=useNavigate()
    const [all,SetAll]=useState([])
    useEffect(()=>{
        getAll().then(res=>{
            console.log(res.data.All,'全部素材')
            SetAll(res.data.All.title)
        })
    },[])
    const handleNameClick=(index)=>{
        console.log(index)
        if(index==0){
            Navigate('/advertisement')
        }else if(index==1){
            Navigate('/ui')
        }
        else if(index==2){
            Navigate('/videoaudio')
        }
        
    }
    return (
        <div className='all'>
            <div className='all_top'>
               <img src='../src/assets/images/6.png'></img>
            </div>
            <div className='all_box'>
                {
                all.map((item,index)=>{
                    return <div key={index} className='title'>
                        <div className='name' onClick={() => handleNameClick(index)}>{item.name}</div>
                        {
                            item.children.map((item2,index2)=>{
                                return <div key={index2}>
                                    <div className='title2'>{item2.title}</div>
                                </div>
                            })
                        }
                    </div>
                })
            }
            </div>
        </div>
    )
}
export default All